import city from './city.json';

export const oceanengine_city_map = city;
// 格式化省市数据
function formatCityData(options) {
    const format = (op) => ({
        key: op.id,
        value: op.name,
        label: op.name,
        parent: op.parent,
    });
    const province = Object.values(options).filter((option) => option.level === 1);
    return province.map((option) => {
        const list = (option.children || [])
            .map((id) => options[id])
            .map((city) => {
                return {
                    ...format(city),
                    children: (city.children || []).map((id) => options[id]).map(format),
                };
            });
        return {
            ...format(option),
            isParentNode: true,
            children: list,
        };
    });
}
export const cityOptionsData = formatCityData(oceanengine_city_map);
